import json

def dump_parser_conf_new():
    # 定义动态参数
    #TODO
    EPOCH = 10
    LR = 5e-4
    NAME = "mix_cl_a50"

    # 读取 JSON 模板
    with open("./parser_conf.json", "r") as f:
        config = json.load(f)

    # 使用动态参数填充占位符
    for key, value in config.items():
        if isinstance(value, str):  # 只对字符串字段进行替换
            config[key] = value.format(NAME=NAME, EPOCH=EPOCH, LR=LR)

    if "num_train_epochs" in config:
        config["num_train_epochs"] = float(config["num_train_epochs"])

    if "learning_rate" in config:
        config["learning_rate"] = float(config["learning_rate"])
    # 将动态生成的配置保存到一个新 JSON 文件
    with open("./parser_conf_new.json", "w") as f:
        json.dump(config, f, indent=4)

    # 打印结果供检查
    print("动态生成的配置：")
    print(json.dumps(config, indent=4))
